package org.yray.sip.packet;

import java.util.HashMap;
import java.util.Map;

public interface IPacket {

    int HEADER_FIRST = 0x1eea;//magic固定表示tea
    int HEADER_RESERVE = 0x8888;//预留域暂固定8888
    int HEADER_RESERVE_RESP = 0x8889;//响应
    long HEADER_SIGN=0x9981886477496636L;     //签名域，暂固定
    int HEADER_PACKET_TYPE=0x0001; //报文类型，JSON固定为1
    int HEX_MSG_REQ_WORD = 0x8001; //语音转后的文字
    int HEX_MSG_REQ_CALL = 0x8002; //外呼
    int HEX_MSG_REQ_SPEAK = 0x8003; //发出语音
    int HEX_MSG_REQ_SIP_ERR = 0x8004;
    int HEX_MSG_REQ_ANSWER = 0x8005;
    int HEX_MSG_REQ_BYE = 0x8006;
    int HEX_MSG_REQ_PLAY_BYE = 0x8007;
    int HEX_MSG_REQ_TO_MAN = 0x8008;
    int HEX_MSG_REQ_BREAK = 0x8009;
    int HEX_MSG_REQ_CANCEL= 0x8010;
    int HEX_MSG_REQ_RECORD= 0x8011;
    int HEX_MSG_REQ_NOTIFY= 0x8012;
    int HEX_MSG_REQ_QUETY=0x8013;
    int HEX_MSG_REQ_HEART= 0x0001;//
    int HEX_MSG_RESP_HEART= 0x0002;
    enum MsgType{
        MSG_REQ_WORD(HEX_MSG_REQ_WORD,"发送句子"),
        MSG_REQ_CALL(HEX_MSG_REQ_CALL,"外呼"),
        MSG_REQ_SPEAK(HEX_MSG_REQ_SPEAK,"说话"),
        MSG_REQ_SIP_ERR(HEX_MSG_REQ_SIP_ERR,"SIP错误"),
        MSG_REQ_ANSWER(HEX_MSG_REQ_ANSWER,"应答指令"),
        MSG_REQ_BYE(HEX_MSG_REQ_BYE,"Bye指令"),
        MSG_REQ_PLAY_BYE(HEX_MSG_REQ_PLAY_BYE,"播报并结束通话"),
        MSG_REQ_TO_MAN(HEX_MSG_REQ_TO_MAN,"转人工"),
        MSG_REQ_BREAK(HEX_MSG_REQ_BREAK,"打断"),
        MSG_REQ_CANCEL(HEX_MSG_REQ_CANCEL,"取消"),
        MSG_REQ_RECORD(HEX_MSG_REQ_RECORD,"录音通知"),
        MSG_REQ_NOTIFY(HEX_MSG_REQ_NOTIFY,"消息通知"),
        MSG_REQ_HEART(HEX_MSG_REQ_HEART,"心跳请求"),
        MSG_RESP_HEART(HEX_MSG_RESP_HEART,"心跳响应"),
        MSG_REQ_QUERY(HEX_MSG_REQ_QUETY,"查询请求"),
        ;

        public static Map<Integer,MsgType> msgTypeMap=new HashMap<>();

        static {
            for(MsgType msgType: MsgType.values())
            {
                msgTypeMap.put(msgType.getValue(),msgType);
            }
        }

        public int getValue() {
            return value;
        }

        public void setValue(int value) {
            this.value = value;
        }

        public String getDisplayName() {
            return displayName;
        }

        public void setDisplayName(String displayName) {
            this.displayName = displayName;
        }

        public static MsgType parseOf(int val)
        {
            return msgTypeMap.get(val);
        }

        private int value;
        private String displayName;
        MsgType(int value,String displayName)
        {
            this.value=value;
            this.displayName=displayName;
        }
    }
}
